package org.liufeng.course.service;

import java.util.Date;
import com.baidu.bae.api.factory.BaeFactory;
import com.baidu.bae.api.memcache.BaeCache;
import java.util.TimerTask;


public class MyTask extends TimerTask {
	
	//cacheId为资源id，memcacheAddr为cache的服务地址和端口（例如，cache.duapp.com:10240）, user为ak, password为sk
	String cacheId ="DXOkKHgtLdSlbtYXMeNi";
	String memcacheAddr ="cache.duapp.com:20243";
	String user ="Ec2chH8MHnfQo9cUi0ga6jw9";
	String pwd ="tP94jTsaYQCj8XkRw8nb3QmmYAFp4OX0";
	
  public void run() {
	  //WriteJsonYQ.WriteJson(RequestService.getYq());  写文件
	  String yqyqJson = RequestService.getYq();
	  String hdswJson = RequestService.getSw();
	  if(!yqyqJson.equals("")){
		  BaeCache baeCache = BaeFactory.getBaeCache(cacheId, memcacheAddr, user, pwd);
		  baeCache.set("yqJson",yqyqJson);
		  baeCache.set("hdswJson", hdswJson);
		  baeCache.set("Time",new Date());
	  }
  }
}
